package com.example.reflection;

import java.util.Random;

/**
 * 能够分析类能力的程序称为反射 reflective
 * Class 类用于存储对象运行时类型标识信息
 */
public class Main {
    public static void main(String[] args) {
        var generator = new Random();
        Class cl = generator.getClass();
        String name = cl.getName();
        System.out.println(name);

        var className = "java.util.Random";
        try {
            Class cl1 = Class.forName(className);
            Object obj = cl1.getConstructor().newInstance();
            System.out.println(obj.toString());
        }catch (Exception e){
            System.out.println(e);
        }

    }
}
